﻿#ifndef PST_SELECTDATADIALOG_H
#define PST_SELECTDATADIALOG_H

#include <QWidget.h>
#include <QModelIndexList>
#include <QPair>
#include <QList>
#include "BaseWidget/IdaDialogFrame.h"
#include "PostEnumType.h"

QT_BEGIN_NAMESPACE
namespace Ui
{
    class SelectDatatDialog;
};
class QComboBox;
class QLineEdit;
QT_END_NAMESPACE

namespace pst
{
    class Curve2DKeySelcetBar;

    class SelectDatatDialog : public IdaDialogFrame
    {
        Q_OBJECT

    public:
        SelectDatatDialog(QWidget* parent = nullptr);
        ~SelectDatatDialog();

        void setDialogTitle(const QString& title);
        QString getDialogTitle() const;

        /// @brief 设置所有key数据
        void setKeyDataList(const QList<QPair<QString, QVector<double>>>& dataList);
        QList<QPair<QString, QVector<double>>> getkeyDataList() const;

        void setValueDataList(const QList<QString>& dataList);
        QList<QString> getValueDataList() const;

        void updateUI();

        void SetHeatMapFlage(bool isHeatMap)
        {
            m_isHeatMap = isHeatMap;
        }

        void set2DPlotType(FileDataType type)
        {
            m_2DPlotType = type;
        }
        void setIsOpenNewWindow(bool isOpenNewWindow)
        {
            m_isOpenNewWindow = isOpenNewWindow;
        }

        void SetOptionalKey(const QList<QString>& optionalKeyList)
        {
            m_optionalKeyList = optionalKeyList;
        }

        void SetSelectParserIndex(const QList<int>& selectParserIndex)
        {
            m_selectParserIndex = selectParserIndex;
        }

    public slots:
        void reject() override;
        void accept() override;
        // void slot_sendChosenInfo();
        void slot_variableIndexChanged(int index);
    signals:
        /// @brief 发送选择的数据信息
        /// variableIndex 选择的变量下标
        /// chosenData 除variableIndex外，选择的每一个变量和对应的数据
        /// valueIndexs 选择的value的下标
        void signal_sendSelectedInfo(int& variableIndex,
            QList<QPair<int, QList<int>>>& chosenData, QList<int>& valueIndexs, bool* isSuccess, QList<int> selectParserIndex);

        // public slots:
        //     void slot_getSelectedInfo(const QModelIndexList& ids);

    private:
        Ui::SelectDatatDialog* m_ui;
        QList<QPair<QString, QVector<double>>> m_keyDataList;
        bool m_isOpenNewWindow{true};
        QList<QString> m_valueNameList;
        QComboBox* m_variableAxisValue;                 // 扫描参数
        QList<Curve2DKeySelcetBar*> m_keySelectBarList; // 所有key列
        Curve2DKeySelcetBar* m_valueSelectBar;          // value列
        QList<QString> m_optionalKeyList;
        QList<int> m_indexMapping;
        bool m_isHeatMap;
        int m_oldVariableIndex;
        QComboBox* m_secondVariable;    // 第二个扫描参数
        QList<int> m_selectParserIndex; //
        FileDataType m_2DPlotType;
    };
} // namespace pst

#endif
